import defaultSettings from '@/settings';

const { title, systemName } = defaultSettings;

const settings = {
  state: {
    title: title,
    systemName: systemName,
  },
  mutations: {
    CHANGE_SETTING: (state, { key, value }) => {
      if (state.hasOwnProperty(key)) {
        state[key] = value
      }
    },
    INIT_SETTINGS: (state, config) => {
      Object.keys(config).map(key => {
        state[key] = config[key]
      })
    }
  },
  actions: {
    changeSetting({ commit }, data) {
      commit('CHANGE_SETTING', data)
    },
    initSettings({ commit }, data) {
      commit('INIT_SETTINGS', data)
    }
  }
};
export default settings;


